<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<!-- $Id: results.php 392 2009-03-10 23:35:33Z cameron.bracken $ -->

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>PondSim Results</title>
    <meta name="author" content="cameron">
    <link rel="stylesheet" type="text/css" href="static/style.css">
    <link rel="shortcut icon" href="img/favicon.ico">
</head>
<body>
	<div id='content'>
		<?php 
			error_reporting(E_ALL ^ E_NOTICE);
			//load all the runtime variables
			include("sandbox/www/vars.php");
			include('includes/geshi/geshi.php');
			include('static/header.html');
		?>
		
	    <h1>PondSim Results</h1>
		<!-- Main Content -->
		
		<?php
			//If the user was redirected fromthe input data page, $_GET will 
			//  contain the run file and the run time, otherwise get the informaiton
			//  from the last run in vars.php
			if(empty($_GET['runfile'])){
				//Not using GET
				$runfile = $loaded_run_file;
			}else{
				//Using GET
				$runfile = $_GET['runfile'];
			}

			if(empty($_GET['time'])){
				//Not using GET
				$t = $loaded_time;
			}else{
				//Using GET
				$t = $_GET['time'];
			}
		?>
		
		<form method='get' action='load-run.php'>
			<?php include('chunks/pulldown.php'); ?>
			<input name='type' style='visibility:hidden;width:0' value='results'>
			<input type='submit' value='Load Results'>
		</form>
		
		<h2>Results of Run</h2>

		<?php
			//If the simulation was successful show the image, otherwise show the log file
			$lines = file("$outdir/pondSim-$t.output");
			if(trim($lines[0])=='1'){
				echo "Simulation Successful!\n";
				
				//Display the png but put a link to the pdf
				echo "<div id='results' style='width:$plot_width;height:$plot_height;'>";
				echo "	<img src='$imgdir/barplot-$t.png' width='100%' height='100%'/></div>";
				echo "<p>Download this image as a <a href='$imgdir/barplot-$t.pdf'>pdf</a></p>\n";
				echo "<p>Download the <a href='$outdir/pondSim-$t.output'>PondSim Output</a></p>\n";
			}else{
				$log = file_get_contents("$logdir/pondSim-$t.log");
				echo "<p style='color:red'>Simulation Unsucessful, Here is the log file:</p>";
				$geshi = new GeSHi($log, 'pondsimlog');
				$geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
				//$geshi->set_header_type(GESHI_HEADER_PRE_VALID);
				//$geshi->set_overall_style('background:#eee;border: 1px solid #ccc;');
				$geshi->set_overall_style('font-family:courier,monospace;');
				echo $geshi->parse_code();
				echo $geshi->error();
			}
		?>

	
		<div id='footer'>
			<!-- menu -->
			<?php include('static/footer.html');?>
			<p>$Id: results.php 392 2009-03-10 23:35:33Z cameron.bracken $</p>
		</div>
	</div>
</body>
</html>
